#ifndef POISSONGENERATOR_H_
#define POISSONGENERATOR_H_

#include <iostream>
#include <vector>
#include "rng.h"
#include <queue>
#include "Position.h"
#include "Scheduler.h"

class PoissonGenerator {
	
public:
	bool requeue(double lambda, Scheduler * s) {
		int num = x.poisson(lambda);
		
		if (num == 0) {
			if (poissonQueue.size() <= 0)
				return false;
			if (s->isEmpty()){
				s->enqueue(poissonQueue.front());
				poissonQueue.pop();
			}
			return true;
		}
		
		for (int i = 0; i < num; i++) {
			if (poissonQueue.size() <= 0)
				return false;
			s->enqueue(poissonQueue.front());
			poissonQueue.pop();
		}
		return true;
	}
	
	void enqueue (Requisition req) {
		poissonQueue.push(req);
	}

private:
	RNG x;
	std::queue<Requisition> poissonQueue;
	
};

#endif /*POISSONGENERATOR_H_*/
